package com.project.design.singleton;

/**
 * 懒汉模式
 * volatile synchronized 多线程下保证线程安全
 */
public class LazSingleton {

    private static volatile LazSingleton instance = null;

    private LazSingleton(){}

    public static synchronized LazSingleton getInstance(){
        if (instance == null){
            instance = new LazSingleton();
        }
        return instance;
    }
}
